﻿#pragma once

#include "../MirEnvir/Envir.h"
#include "../MessageQueue.h"
#include "../../Shared/Enums.h"
#include "../../Shared/Data/Stat.h"
#include "../../Shared/Data/ItemData.h"
#include <string>
#include <vector>
#include <algorithm>
#include "../../stringhelper.h"
#include "../../tangible_filesystem.h"

//C# TO C++ CONVERTER NOTE: Forward class declarations:
namespace Server::MirDatabase { class DropInfo; }

using namespace Server::MirEnvir;

namespace Server::MirDatabase
{
    class MonsterInfo
    {
    public:
        virtual ~MonsterInfo()
        {
            delete Stats;
        }

    protected:
        static Server::MirEnvir::Envir *getEnvir();

        static Server::MirEnvir::Envir *getEditEnvir();

        static Server::MessageQueue *getMessageQueue();

    public:
        int Index = 0;
        std::string Name = std::string::Empty;

        Monster Image = static_cast<Monster>(0);
        unsigned char AI = 0, Effect = 0, ViewRange = 7, CoolEye = 0;
        unsigned short Level = 0;

        unsigned char Light = 0;

        unsigned short AttackSpeed = 2500, MoveSpeed = 1800;
        unsigned int Experience = 0;

        std::vector<DropInfo*> Drops = std::vector<DropInfo*>();

        bool CanTame = true, CanPush = true, AutoRev = true, Undead = false;

        bool HasSpawnScript = false;
        bool HasDieScript = false;

        Stats *Stats;

        MonsterInfo();

        MonsterInfo(BinaryReader *reader);

        std::string getGameName() const;

        void Save(BinaryWriter *writer);

        void LoadDrops();

        static void FromText(const std::string &text);
        std::string ToText();

        std::string ToString();

    };

    class DropInfo
    {
    public:
        virtual ~DropInfo()
        {
            delete Item;
        }

    protected:
        static Server::MirEnvir::Envir *getEnvir();

    public:
        int Chance = 0;
        ItemInfo *Item;
        unsigned int Gold = 0;

        unsigned char Type = 0;
        bool QuestRequired = false;

        static DropInfo *FromLine(const std::string &s);
    };
}
